package com.example.stumanager.student;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.stumanager.R;
import com.example.stumanager.database.PaySql;
import com.example.stumanager.entity.PayEntity;
//缴费
public class StudentPayPage extends AppCompatActivity {
    EditText t1,t2  ;
    Button re;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.student_pay_page);
        t1=findViewById(R.id.et_c_account);
        t2=findViewById(R.id.et_c_oldpassword);
        re = findViewById(R.id.re);
        re.setOnClickListener(view -> finish());
        Button submit=findViewById(R.id.button_change_password_ok);
        submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(t1.getText().toString().equals("") ||
                        t2.getText().toString().equals("")){
                    Toast.makeText(StudentPayPage.this, "不能为空", Toast.LENGTH_SHORT).show();
                    return ;
                }
                PayEntity f=new PayEntity(t2.getText().toString(),t1.getText().toString(),
                       "6000" );
                PaySql db=new PaySql(getBaseContext());
                if(db.add(f)){
                    Toast.makeText(StudentPayPage.this, "缴费成功", Toast.LENGTH_SHORT).show();

                }else{
                    Toast.makeText(StudentPayPage.this, "缴费失败，此学号已缴费", Toast.LENGTH_SHORT).show();
                }

            }
        });

    }
}